//
//  SerOrderDetailViewController.m
//  BaseProject
//
//  Created by 王洋 on 2020/7/30.
//  Copyright © 2020 王洋. All rights reserved.
//
#import "CommonOrderDetailModel.h"

#import "SerOrderDetailStatusCell.h"
#import "SerOrderDetailContactCell.h"
#import "SerOrderDetailSerCell.h"
#import "SerOrderDetailMarkCell.h"
#import "SerOrderDetailInfoCell.h"
#import "OrderDetailNoCopyCell.h"


#import "SerOrderDetailPackageCell.h"
#import "SerOrderDetailFieldCell.h"
#import "SerOrderDetailMenuCell.h"

#import "OrderDetailContactSectionFooter.h"

#import "OrderDetailBottomView.h"

#import "ApplyRefundViewController.h"
#import "RefundDetailViewController.h"

#import "SerOrderDetailViewController.h"

@interface SerOrderDetailViewController ()<UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong) UITableView *tableview;

@property (nonatomic, strong) CommonOrderDetailModel *model;

@property (nonatomic, strong) OrderDetailBottomView *bottomView;

@end

@implementation SerOrderDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    [self initView];
    [self request_orderDetail];
}

- (void)goBack {
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)initView {

    self.title = @"订单详情";
    self.view.backgroundColor = UIColorHex(0xf1f1f1);

    self.bottomView =  [[NSBundle mainBundle] loadNibNamed:@"OrderDetailBottomView"owner:nil options:nil].firstObject;
    
    [self.view addSubview:self.bottomView];
    [self.view addSubview:self.tableview];

    [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.bottom.right.mas_equalTo(0);
        make.height.mas_equalTo(Bottom_SafeHeight + 60);
    }];

    [self.tableview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.bottom.mas_equalTo(self.bottomView.mas_top);
        make.top.mas_equalTo(0);
    }];
    
    [self initViewAction];
}

- (void)initViewAction {
    
    WEAKSELF
    self.bottomView.OrderDetailBottomViewBlock = ^(NSInteger index) {
      
        switch (index) {
            case 0:{
                ApplyRefundViewController *vc = [[ApplyRefundViewController alloc] init];
                vc.paramModel = [[ApplyRefundParamModel alloc] init];
                vc.paramModel.orderNo = weakSelf.model.uoOrderNo;
                vc.paramModel.payAmount = weakSelf.model.uodPayAmount;
                [weakSelf.navigationController pushViewController:vc animated:YES];
            } break;
            case 1:{
                RefundDetailViewController *vc = [[RefundDetailViewController alloc] init];
                [weakSelf.navigationController pushViewController:vc animated:YES];
            } break;
            default:
                break;
        }
    };
}

#pragma mark UITableviewDelegate
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
//    return self.dataArray.count;
    return 8;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    switch (section) {
        case SerOrderDetailSectionType_status:{
            return 1;
        } break;
        case SerOrderDetailSectionType_address:{
            return 2;
        } break;
        case SerOrderDetailSectionType_server:{
            return 1;
        } break;
        case SerOrderDetailSectionType_mark:{
            return 1;
        } break;
        case SerOrderDetailSectionType_payType:{
            return 2;
        } break;
        case SerOrderDetailSectionType_payStep:{
            switch (self.model.uoType) {
                case 1:
                case 2:{
                    return 2;
                } break;
                case 3:{
                    return 0;
                } break;
                default:{
                    return 0;
                } break;
            }
        } break;
        case SerOrderDetailSectionType_payDetails:{
            return 5;
        } break;
        case SerOrderDetailSectionType_orderInfo:{
            return 2;
        } break;
        default:
            break;
    }
    return 0;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    switch (indexPath.section) {
        case SerOrderDetailSectionType_status:{
            return 60;
        } break;
        case SerOrderDetailSectionType_address:{

            switch (indexPath.row) {
                case 0:{
                    return 50;
                } break;
                case 1:{
                    
                    if (self.model.uodServiceTime.length > 0) {
                        return 50;
                    } else {
                        return CGFLOAT_MIN;
                    }
                    
                } break;
                default:
                    break;
            }

        } break;
        case SerOrderDetailSectionType_server:{
            return 130;
        } break;
        case SerOrderDetailSectionType_mark:{
                        
            return [Utilities getStringHeightWithText:self.model.uoRemark font:[UIFont systemFontOfSize:14] viewWidth:(TTScreenWidth-100)] + 20 ;
            
        } break;
        case SerOrderDetailSectionType_payType:{
            return 50;
        } break;
        case SerOrderDetailSectionType_payStep:{

            //等待付定金的时候，显示，其他时候不显示
            switch (self.model.uodStatus) {
                case SerCellOrderType_payDJ:
                case SerCellOrderType_waitPay:
                case SerCellOrderType_recOrder:
                case SerCellOrderType_payWK:{

                    return 50;
                    } break;
                    
                default:{
                    return CGFLOAT_MIN;;
                } break;
            }
            
//            if (self.model.uodStatus == SerCellOrderType_payDJ) {
//                return 50;
//            } else {
//                return CGFLOAT_MIN;;
//            }

        } break;
        case SerOrderDetailSectionType_payDetails:{
            
            switch (indexPath.row) {
                case SerOrderPayDetailCellType_dingjin:
                case SerOrderPayDetailCellType_weikuan:{
                    
                    //1,定金2尾款3：全款
                    switch (self.model.uoType) {
                        case 1:
                        case 2:{
                            
                            switch (self.model.uodStatus) {
                                case SerCellOrderType_payDJ:
                                case SerCellOrderType_waitPay:
                                case SerCellOrderType_recOrder:
                                case SerCellOrderType_payWK:{
                                    return CGFLOAT_MIN;
                                } break;
                                default:{
                                    return 50;
                                } break;
                            }
                        } break;
                        case 3:{
                            return CGFLOAT_MIN;;
                        } break;
                        default:
                            break;
                    }
                } break;
                case SerOrderPayDetailCellType_coupon:{
                    return 50;

                } break;
                case SerOrderPayDetailCellType_pingtaijintie:{
                    return 50;

                } break;
                case SerOrderPayDetailCellType_totalPay:{
                    
                    if (self.model.uoType == 3) {
                        return 50;
                    }
                    
                    if (self.model.uodStatus >=4) {
                        return 50;
                    } else {
                        return CGFLOAT_MIN;
                    }
                                        
                } break;
                default:
                    break;
            }
            
            
            return 50;
        } break;
        case SerOrderDetailSectionType_orderInfo:{
            return 50;
        } break;
        default:
            break;
    }
    return CGFLOAT_MIN;
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 5;
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    
    if (section == SerOrderDetailSectionType_server) {
        return 40;
    }
    return CGFLOAT_MIN;
}

#pragma mark sectionheader
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    return  [UIView new];
}

-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    
    if (section == SerOrderDetailSectionType_server) {
        OrderDetailContactSectionFooter *footerView  =  [[NSBundle mainBundle] loadNibNamed:@"OrderDetailContactSectionFooter"owner:nil options:nil].firstObject;
        
        WEAKSELF
        footerView.ServiceCatSubSegNaviBlock = ^(OrderDetailContactActionType type) {
          
            switch (type) {
                case OrderDetailContactActionType_im:{
                    
                    [[TT_IMContactManager manager] ImContactWithStoreId:weakSelf.model.uodSellerId];
                } break;
                case OrderDetailContactActionType_call:{
                    
                    [[TT_PhonaCallManager manager] callWithStoreId:weakSelf.model.uodSellerId];
                } break;
                default:
                    break;
            }
        };
        return footerView;
    }
    
    return  [UIView new];
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    switch (indexPath.section) {
        case SerOrderDetailSectionType_status:{

            SerOrderDetailStatusCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SerOrderDetailStatusCellID"];
            cell.selectionStyle =UITableViewCellSelectionStyleNone;
            [cell fillCellWithModel:self.model];
            return cell;

        } break;
        case SerOrderDetailSectionType_address:{

            switch (indexPath.row) {
                case 0:{
                    
                    SerOrderDetailContactCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SerOrderDetailContactCellID"];
                    cell.selectionStyle =UITableViewCellSelectionStyleNone;
                    cell.mainTitle.text = self.model.uoUserName;
                    cell.contentLab.text = self.model.uoUserTel;
                    return cell;
                    
                } break;
                case 1:{
                    
                    SerOrderDetailContactCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SerOrderDetailContactCellID"];
                    cell.selectionStyle =UITableViewCellSelectionStyleNone;
                    
                    cell.mainTitle.text = @"服务时间";
                    cell.contentLab.text = self.model.uodServiceTime;
                    return cell;
                    
                } break;
                default:
                    break;
            }
            


        } break;
        case SerOrderDetailSectionType_server:{

//            switch (indexPath.row) {
//                case 0:{
            SerOrderDetailPackageCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SerOrderDetailPackageCellID"];
            cell.selectionStyle =UITableViewCellSelectionStyleNone;
            [cell fillCellWithModel:self.model];
        
            return cell;

        } break;
        case SerOrderDetailSectionType_mark:{

            SerOrderDetailMarkCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SerOrderDetailMarkCellID"];
            cell.selectionStyle =UITableViewCellSelectionStyleNone;
            cell.itemContentLab.text = self.model.uoRemark;
            return cell;

        } break;
        case SerOrderDetailSectionType_payType:{

            switch (indexPath.row) {
                case SerOrderPayCellType_payType:{
                    
                    SerOrderDetailInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SerOrderDetailInfoCellID"];
                    cell.selectionStyle =UITableViewCellSelectionStyleNone;
                    
                    cell.mainTitle.text = @"支付类型";
                    cell.contentLab.textColor = UIColorHex(0x333333);
                    switch (self.model.uoType) {
                        case 1:
                        case 2:{
                            cell.contentLab.text = @"定金支付";
                        } break;
                        case 3:{
                            cell.contentLab.text = @"全款支付";
                        } break;
                        default:
                            break;
                    }
                    cell.subTitle.hidden = YES;
                    return cell;
                    
                } break;
                case SerOrderPayCellType_packagePrice:{
                    
                    SerOrderDetailInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SerOrderDetailInfoCellID"];
                    cell.selectionStyle =UITableViewCellSelectionStyleNone;
                    
                    cell.mainTitle.text = @"套餐价格";
                    cell.contentLab.textColor = UIColorHex(0x333333);
                    cell.contentLab.text =[NSString stringWithFormat:@"¥%@",[Utilities changeDoubleToString:self.model.uodTotal]];
                    cell.subTitle.hidden = YES;
                    return cell;
                    
                } break;
                default:
                    break;
            }
            
        } break;
        case SerOrderDetailSectionType_payStep:{

            switch (indexPath.row) {
                case SerOrderPayStepCellType_dingjin:{
                    
                    SerOrderDetailInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SerOrderDetailInfoCellID"];
                    cell.selectionStyle =UITableViewCellSelectionStyleNone;
                    
                    switch (self.model.uodStatus) {
                        case SerCellOrderType_recOrder:
                        case SerCellOrderType_payWK:{
                            cell.mainTitle.text = @"定金：已支付";
                            cell.mainTitle.textColor = UIColorHex(0x333333);
                            cell.contentLab.textColor = UIColorHex(0x333333);
                            cell.subTitle.textColor = UIColorHex(0x333333);
                        } break;
                        default:{
                            cell.mainTitle.text = @"定金：待支付";
                            cell.mainTitle.textColor = UIColorHex(0xff2442);
                            cell.contentLab.textColor = UIColorHex(0xff2442);
                            cell.subTitle.textColor = UIColorHex(0xff2442);

                        } break;
                    }
                    
                    cell.contentLab.text = [NSString stringWithFormat:@"¥%@",[Utilities changeDoubleToString:self.model.uodDeposit]];
                    cell.subTitle.hidden = YES;

                    return cell;
                    
                } break;
                case SerOrderPayStepCellType_weikuan:{
                    
                    SerOrderDetailInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SerOrderDetailInfoCellID"];
                    cell.selectionStyle =UITableViewCellSelectionStyleNone;
                    cell.subTitle.hidden = YES;
                    switch (self.model.uodStatus) {
                        case SerCellOrderType_payWK:{
                            cell.mainTitle.text = @"尾款：未开始";
                            cell.mainTitle.textColor = UIColorHex(0xff2442);
                            cell.contentLab.textColor = UIColorHex(0xff2442);
                            cell.subTitle.textColor = UIColorHex(0xff2442);
                        } break;
                        default:{
                            cell.mainTitle.text = @"尾款：未开始";
                            cell.mainTitle.textColor = UIColorHex(0x333333);
                            cell.contentLab.textColor = UIColorHex(0x333333);
                            cell.subTitle.textColor = UIColorHex(0x333333);
                        } break;
                    }
                    

                    cell.subTitle.text = @"(所有优惠尾款可使用）";
                    cell.contentLab.text = [NSString stringWithFormat:@"¥%@",[Utilities changeDoubleToString:self.model.uodBalance]];
                    //                    cell.contentLab.text = [NSString stringWithFormat:@"¥%@",[Utilities changeDoubleToString:(self.model.uodTotal - self.model.uodDeposit - self.model.uodDiscountMcAmount - self.model.uodDiscountPcAmount)]];

                    cell.subTitle.hidden = NO;

                    return cell;
                    
                } break;
                default:
                    break;
            }

        } break;
        case SerOrderDetailSectionType_payDetails:{

            switch (indexPath.row) {
                case SerOrderPayDetailCellType_dingjin:{
                    
                    SerOrderDetailInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SerOrderDetailInfoCellID"];
                    cell.selectionStyle =UITableViewCellSelectionStyleNone;
                    
                    cell.mainTitle.text = @"定金：已支付";
                    cell.contentLab.text = [NSString stringWithFormat:@"¥%@",[Utilities changeDoubleToString:self.model.uodDeposit]];
                    cell.subTitle.hidden = NO;
                    
                    if (self.model.uodStatus >= SerCellOrderType_payWK) {
                        cell.mainTitle.text = @"定金：已支付";
                        cell.subTitle.text = @"";
                        cell.contentLab.textColor = UIColorHex(0x333333);
                        
                        if (self.model.uodStatus == SerCellOrderType_cancle || self.model.uodStatus == SerCellOrderType_sysClose) {
                            cell.mainTitle.text = @"定金：未支付";
                        }
                    }

                    return cell;
                    
                } break;
                case SerOrderPayDetailCellType_weikuan:{
                    
                    SerOrderDetailInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SerOrderDetailInfoCellID"];
                    cell.selectionStyle =UITableViewCellSelectionStyleNone;
                    
//                    cell.contentLab.text = [NSString stringWithFormat:@"¥%@",[Utilities changeDoubleToString:(self.model.uodTotal - self.model.uodDeposit - self.model.uodDiscountMcAmount - self.model.uodDiscountPcAmount)]];
                    cell.contentLab.text = [NSString stringWithFormat:@"¥%@",[Utilities changeDoubleToString:self.model.uodBalance]];

                    cell.subTitle.hidden = NO;

                    if (self.model.uodStatus == SerCellOrderType_payWK) {
                        cell.mainTitle.text = @"尾款：待支付";
                    }
                    
                    if (self.model.uodStatus > SerCellOrderType_payWK) {
                        
                        cell.mainTitle.text = @"尾款：已支付";
                        cell.subTitle.text = @"";
                        cell.contentLab.textColor = UIColorHex(0x333333);
                        
                        if (self.model.uodStatus == SerCellOrderType_cancle || self.model.uodStatus == SerCellOrderType_sysClose) {
                            cell.mainTitle.text = @"尾款：未支付";
                        }
                    }
                    
                    
                    return cell;
                    
                } break;
                case SerOrderPayDetailCellType_coupon:{
                    
                    SerOrderDetailInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SerOrderDetailInfoCellID"];
                    cell.selectionStyle =UITableViewCellSelectionStyleNone;
                    
                    cell.mainTitle.text = @"优惠券";
                    cell.contentLab.text = [NSString stringWithFormat:@"-¥%@",[Utilities changeDoubleToString:self.model.uodDiscountMcAmount]];
                    cell.subTitle.hidden = YES;

                    return cell;
                    
                } break;
                case SerOrderPayDetailCellType_pingtaijintie:{
                    
                    SerOrderDetailInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SerOrderDetailInfoCellID"];
                    cell.selectionStyle =UITableViewCellSelectionStyleNone;
                    
                    cell.mainTitle.text = @"平台津贴";
                    cell.contentLab.text = [NSString stringWithFormat:@"-¥%@",[Utilities changeDoubleToString:self.model.uodDiscountPcAmount]];
                    cell.subTitle.hidden = YES;

                    return cell;
                    
                } break;
                case SerOrderPayDetailCellType_totalPay:{
                    
                    SerOrderDetailInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SerOrderDetailInfoCellID"];
                    cell.selectionStyle =UITableViewCellSelectionStyleNone;
                    
                    cell.mainTitle.text = @"实付金额";
                    cell.contentLab.text = [NSString stringWithFormat:@"¥%@",[Utilities changeDoubleToString:self.model.uodPayAmount]];
                    cell.subTitle.hidden = YES;

                    return cell;
                    
                } break;
                default:
                    break;
            }


        } break;
        case SerOrderDetailSectionType_orderInfo:{

            switch (indexPath.row) {
                case SerOrderInfoCellType_orderNo:{
                    
                    OrderDetailNoCopyCell *cell = [tableView dequeueReusableCellWithIdentifier:@"OrderDetailNoCopyCellID"];
                    cell.selectionStyle =UITableViewCellSelectionStyleNone;
                    cell.itemContentLab.text = self.model.uoOrderNo;
                    
                    cell.OrderDetailNoCopyCellBlock = ^{
                      
                        UIPasteboard *pastboard = [UIPasteboard generalPasteboard];
                        [pastboard setString:self.model.uoOrderNo];
                        
                        [SVProgressHUD showSuccessWithStatus:[NSString stringWithFormat:@"已复制%@",self.model.uoOrderNo]];
                        [SVProgressHUD dismissWithDelay:1];
                    };
                    
                    return cell;
                    
                } break;
                case SerOrderInfoCellType_orderCTime:{
                    
                    SerOrderDetailInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SerOrderDetailInfoCellID"];
                    cell.selectionStyle =UITableViewCellSelectionStyleNone;
                    
                    cell.mainTitle.text = @"创建时间";
                    cell.contentLab.textColor = UIColorHex(0x333333);
                    cell.contentLab.text = self.model.uoCreateTime;
                    cell.subTitle.hidden = YES;
                    return cell;
                } break;
                default:
                    break;
            }

        } break;
        default:
            break;
    }
    
    SerOrderDetailStatusCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SerOrderDetailStatusCellID"];
    cell.selectionStyle =UITableViewCellSelectionStyleNone;
//    [cell fillCellWithModel:self.dataArray[indexPath.section].goodsList[indexPath.row]];
    
    return cell;
}

- (UITableView *)tableview {
    if (!_tableview) {
        _tableview = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStyleGrouped];
        _tableview.delegate = self;
        _tableview.dataSource = self;
        _tableview.separatorStyle = UITableViewCellSeparatorStyleNone;
        _tableview.backgroundColor =  [UIColor clearColor];
        
        _tableview.showsHorizontalScrollIndicator = NO;
        _tableview.showsVerticalScrollIndicator = NO;
        
        _tableview.estimatedSectionHeaderHeight = 0;
        _tableview.estimatedSectionFooterHeight = 0;
        _tableview.estimatedRowHeight = 0;
        

        [_tableview registerNib:[UINib nibWithNibName:@"SerOrderDetailPackageCell" bundle:nil] forCellReuseIdentifier:@"SerOrderDetailPackageCellID"];

        [_tableview registerNib:[UINib nibWithNibName:@"SerOrderDetailFieldCell" bundle:nil] forCellReuseIdentifier:@"SerOrderDetailFieldCellID"];

        [_tableview registerNib:[UINib nibWithNibName:@"SerOrderDetailMenuCell" bundle:nil] forCellReuseIdentifier:@"SerOrderDetailMenuCellID"];
        
        
        [_tableview registerNib:[UINib nibWithNibName:@"SerOrderDetailStatusCell" bundle:nil] forCellReuseIdentifier:@"SerOrderDetailStatusCellID"];
        
        [_tableview registerNib:[UINib nibWithNibName:@"SerOrderDetailContactCell" bundle:nil] forCellReuseIdentifier:@"SerOrderDetailContactCellID"];

        
        [_tableview registerNib:[UINib nibWithNibName:@"SerOrderDetailSerCell" bundle:nil] forCellReuseIdentifier:@"SerOrderDetailSerCellID"];

        [_tableview registerNib:[UINib nibWithNibName:@"SerOrderDetailMarkCell" bundle:nil] forCellReuseIdentifier:@"SerOrderDetailMarkCellID"];
        
        [_tableview registerNib:[UINib nibWithNibName:@"SerOrderDetailInfoCell" bundle:nil] forCellReuseIdentifier:@"SerOrderDetailInfoCellID"];
        
        [_tableview registerNib:[UINib nibWithNibName:@"OrderDetailNoCopyCell" bundle:nil] forCellReuseIdentifier:@"OrderDetailNoCopyCellID"];

    }
    return _tableview;
}

- (CommonOrderDetailModel *)model {
    if (!_model) {
        _model = [[CommonOrderDetailModel alloc] init];
    }
    return _model;
}

//
- (void)request_orderDetail {
    
    NSString *url = [NSString stringWithFormat:@"%@%@",TT_Global_Api_Domain,API_OrderDetail];
    
    NSMutableDictionary *dic = @{}.mutableCopy;
    [dic setValue:self.orderId forKey:@"uoId"];
    [dic setValue:@"1" forKey:@"uodOrderType"];
    [dic setValue:[TTUserModel sharedObject].userId forKey:@"uoUserId"];

    WEAKSELF
    [SVProgressHUD showWithStatus:@"正在加载"];
    [TTHttpManager postRequestWithUrl:url TimeOut:10 PostData:dic FinishBlock:^(id  _Nonnull data) {
        
        [SVProgressHUD dismiss];
        
        if ([data isKindOfClass:[NSDictionary class]]) {
            //请求成功
            NSInteger code = [[data valueForKey:@"code"] integerValue];
            if (code == 10000) {
                NSDictionary *resultDic = [data valueForKey:@"data"];
                if ([resultDic isKindOfClass:[NSDictionary class]]) {
                    
                    weakSelf.model = [CommonOrderDetailModel modelWithDictionary:resultDic];
//                    NSArray *refundFlowList = [resultDic valueForKey:@"refundFlowList"];
                    NSArray *userOrderGoodsVoList = [resultDic valueForKey:@"userOrderGoodsVoList"];
                    
                    if ([userOrderGoodsVoList isKindOfClass:[NSArray class]]) {
                        weakSelf.model.userOrderGoodsVoList = @[].mutableCopy;
                        
                        for (int i = 0; i < userOrderGoodsVoList.count; i++) {
                            
                            NSDictionary *goodsDic = userOrderGoodsVoList[i];
                            CommonOrderGoodsModel *goodsModel = [CommonOrderGoodsModel modelWithDictionary:goodsDic];
                            
                            [weakSelf.model.userOrderGoodsVoList addObject:goodsModel];
                        }
                    }
                    [weakSelf.tableview reloadData];
                }
            }
        }
        
    } FailedBlock:^(NSError * _Nonnull error) {
        [SVProgressHUD dismiss];
    }];
}


@end
